package com.example.onedemotest.slice;

import com.example.onedemotest.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.PageSlider;

import java.util.ArrayList;

/**
 * 测试PageSlice 的相关API
 */
public class PageSliderSlice extends AbilitySlice {

    private PageSlider pageSlider;
    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        setUIContent(ResourceTable.Layout_ability_page_slider_layout);
        pageSlider= (PageSlider) findComponentById(ResourceTable.Id_pageSlider);
        initPageSlider();
    }

    private void initPageSlider() {
        pageSlider.setProvider(new PageSliderProvider(getData(),this));
    }
    private ArrayList<PageSliderProvider.DataItem> getData() {
        ArrayList<PageSliderProvider.DataItem> dataItems = new ArrayList<>();
        dataItems.add(new PageSliderProvider.DataItem("Page A"));
        dataItems.add(new PageSliderProvider.DataItem("Page B"));
        dataItems.add(new PageSliderProvider.DataItem("Page C"));
        dataItems.add(new PageSliderProvider.DataItem("Page D"));
        return dataItems;
    }
}
